import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/viewmodel/medecine/receive_medicine/choose_medicine_view_model.dart';
class ChooseMedicinePage extends BaseStatefulMvvmWidget{
  @override
  State<StatefulWidget> createState() => _ChooseMedicineState();

}

class _ChooseMedicineState extends BaseMvvmListState<ChooseMedicineViewModel,ChooseMedicinePage>{
  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      backgroundColor: Colours.bg_color,
      appBar: AppBar(
        title: Text('选择药品'),
      ),
      body: loadingContentWidget,
    );
  }

  @override
  Widget createItemWidget(int index) {
    var item = viewModel.listItems[index];
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        CommonText('${item.commonName??""}',textColor: Colors.blue,fontWeight: FontWeight.bold,textSize: 18),
        Row(
          children: [
            CommonText('药品规格：${item.specifications}').setWeight(3),
            CommonText('剂型：${item.doseTypeName}').setWeight(2),
          ],
        ),
        Row(
          children: [
            CommonText('最小单位(服药单位)：${item.minUnitName}').setWeight(3),
            CommonText('处方药：${item.prescriptionFlag==1?'是':'否'}').setWeight(2),
          ],
        ),

        Row(
          children: [
            CommonText('剂量：${item.doseNum}').setWeight(3),
            CommonText('剂量单位：${item.doseUnitName}').setWeight(2),
          ],
        ),

        Row(
          children: [
            CommonText('包装量：${item.unitNum}').setWeight(3),
            CommonText('包装单位：${item.maxUnitName}').setWeight(2),
          ],
        ),
      ].insertWidget(SizedBox(height: 10,)),
    ).onTap(() {
      Go().pop(result: item);
    }).addToContainer(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: 6.borderRadius
      ),
      padding: EdgeInsets.symmetric(horizontal: 10,vertical: 10)
    );
  }

  @override
  ChooseMedicineViewModel createViewModel() {
    return ChooseMedicineViewModel(context);
  }

  @override
  EdgeInsets get listPadding => EdgeInsets.symmetric(horizontal: 16,vertical: 12);

  @override
  Widget get separatorDivider => SizedBox(height: 12,);
}